<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->

<lv-form [formGroup]='formGroup' [lvLabelColon]="false" class="formGroup">
    <lv-form-item>
        <lv-form-label lvRequired>{{'common_name_label' | i18n}}</lv-form-label>
        <lv-form-control [lvErrorTip]="nameErrorTip">
            <input lv-input formControlName='name' />
        </lv-form-control>
    </lv-form-item>
    <lv-form-item>
        <lv-form-label lvRequired>{{'common_type_label' | i18n}}</lv-form-label>
        <lv-form-control>
            <lv-select [lvOptions]='typeOptions' lvValueKey='value' formControlName='type'>
            </lv-select>
            <span class="rule-desc">{{ruleExplanation}}</span>
        </lv-form-control>
    </lv-form-item>
    <ng-container *ngIf="includes([dataMap.format.value],formGroup.value.type)">
        <lv-form-item>
            <lv-form-label lvRequired>{{'explore_anonymization_alphabet_label' | i18n}}</lv-form-label>
            <lv-form-control [lvErrorTip]="alphabetErrorTip">
                <input lv-input formControlName='maskAlphabet'
                    placeholder="{{'explore_alphabet_range_label' | i18n}}" />
            </lv-form-control>
        </lv-form-item>
    </ng-container>
    <ng-container *ngIf="includes([dataMap.fullMask.value, dataMap.partialMask.value],formGroup.value.type)">
        <lv-form-item>
            <lv-form-label lvRequired>{{'explore_anonymization_mask_character_label' | i18n}}</lv-form-label>
            <lv-form-control [lvErrorTip]="maskErrorTip">
                <input lv-input formControlName='maskCharacter' />
            </lv-form-control>
        </lv-form-item>
    </ng-container>
    <ng-container *ngIf="includes([dataMap.fullMask.value],formGroup.value.type)">
        <lv-form-item>
            <lv-form-label lvRequired>{{'explore_mask_character_length_label' | i18n}}</lv-form-label>
            <lv-form-control [lvErrorTip]="lenErrorTip">
                <input lv-input formControlName='maskLength' placeholder='1~32' />
            </lv-form-control>
        </lv-form-item>
    </ng-container>
    <ng-container *ngIf="includes([dataMap.partialMask.value],formGroup.value.type)">
        <lv-form-item>
            <lv-form-label lvRequired>
                {{'explore_mask_character_length_label' | i18n}}
                <i lv-icon="aui-icon-help" lv-tooltip="{{'explore_mask_character_length_help_label' | i18n}}"
                    lvTooltipPosition="top" lvTooltipTheme="light" class="configform-constraint"
                    lvColorState='true'></i>
            </lv-form-label>
            <lv-form-control [lvErrorTip]="maskLengthErrorTip">
                <input lv-input formControlName='maskCharacterLength' placeholder='0~32' />
            </lv-form-control>
        </lv-form-item>
        <lv-form-item>
            <lv-form-label lvRequired>{{'explore_anonymization_mask_index_label' | i18n}}</lv-form-label>
            <lv-group lvGutter='8px'>
                <lv-form-control [lvErrorTip]="startErrorTip">
                    <input lv-input formControlName='startIndex'
                        placeholder="{{'explore_start_index_placeholder_label' | i18n}}(1~32)" />
                </lv-form-control>
                <lv-form-control [lvErrorTip]="endErrorTip">
                    <input lv-input formControlName='stopIndex'
                        placeholder="{{'explore_stop_index_placeholder_label' | i18n}}(1~32)" />
                </lv-form-control>
            </lv-group>
        </lv-form-item>
    </ng-container>
    <ng-container *ngIf="includes([dataMap.numberic.value],formGroup.value.type)">
        <lv-form-item>
            <lv-form-label lvRequired>{{'explore_anonymization_range_number_label' | i18n}}</lv-form-label>
            <lv-group lvGutter='8px'>
                <lv-form-control [lvErrorTip]="minErrorTip">
                    <input lv-input formControlName='minNumber'
                        placeholder="{{'explore_min_number_placeholder_label' | i18n}}(-65535~65536)" />
                </lv-form-control>
                <lv-form-control [lvErrorTip]="maxErrorTip">
                    <input lv-input formControlName='maxNumber'
                        placeholder="{{'explore_max_number_placeholder_label' | i18n}}(-65535~65536)" />
                </lv-form-control>
            </lv-group>
        </lv-form-item>
    </ng-container>
    <ng-container *ngIf="includes([dataMap.fixedNumber.value],formGroup.value.type)">
        <lv-form-item>
            <lv-form-label lvRequired>{{'explore_anonymization_number_fixed_label' | i18n}}</lv-form-label>
            <lv-form-control [lvErrorTip]="fixedErrorTip">
                <input lv-input formControlName='fixedNumber' placeholder='-65535~65536' />
            </lv-form-control>
        </lv-form-item>
    </ng-container>
    <ng-container *ngIf="formGroup.value.type !== dataMap.format.value">
        <lv-form-item>
            <lv-form-label>{{'explore_anonymization_original_data_label' | i18n}}</lv-form-label>
            <lv-form-control [lvErrorTip]="testDataErrorTip">
                <lv-group lvGutter='8px' class="original-group">
                    <input lv-input formControlName='originalData' class="original-input" />
                    <button (click)="generateData()"
                        [disabled]="!formGroup.value.originalData || formGroup.get('originalData').status !== 'VALID' || formGroup.status !== 'VALID'"
                        lv-button>{{'explore_anonymization_generate_example_label' | i18n}}</button>
                </lv-group>
            </lv-form-control>
        </lv-form-item>
        <lv-form-item>
            <lv-form-label>{{'explore_rule_details_label' | i18n}}</lv-form-label>
            <lv-form-control>
                <lv-input-lint>
                    <textarea formControlName="description"
                        placeholder="{{'explore_anonymization_example_placeholder_label' | i18n}}" rows='6' lv-input
                        style="resize: vertical;" readOnly></textarea>
                </lv-input-lint>
            </lv-form-control>
        </lv-form-item>
    </ng-container>
</lv-form>